//
//  main.m
//  first-oc.class-method-2
//
//  Created by 郭志远 on 2023/11/23.
//

#import <Foundation/Foundation.h>
// 1.编写类的声明

typedef enum
{
    kIColorBlack,
    kIColorWhite,
    kIColorTuHaoJin,
} IColor;

@interface Iphone : NSObject
{

    @public
    float _model;
    int _cpu;
    double _size;
//    int _color;
    IColor _color;
}

//行为
//OC中类方法用+表示，对象方法用-表示
//没参数没返回
- (void)about;
//没参数又返回
- (char *)loadMessage;
//有参数又返回
//注意：OC中的方法如果有采纳数，那么每个参数的数据类型前面必须加一个:
//冒号也是方法名的一部分
- (void)signal:(int)number;

- (int)sendMessageWithNumber:(int)number andContent:(char *)content;


//计算器
+ (int)sum:(int)value1  :(int)value2;

+ (NSString *)colorWithNumber:(IColor)number;

@end


// 2.如何编写类的实现

@implementation Iphone
- (void)about
{

    NSString *name = [Iphone colorWithNumber: _color];
   
    NSLog(@"打印本机信息: 型号 = %f, cpu = %i, 大小 = %f, 颜色 = %@", _model, _cpu, _size, name);
}

+ (NSString *)colorWithNumber:(IColor)number
{
    NSString *name;
    switch (number) {
        case 0:
            name = @"黑色";
            break;
        case 1:
            name = @"白色";
            break;
        case 2:
            name = @"土豪金";
            break;
        default:
            name = @"华强北";
            break;
    }
    return name;
}

- (char *)loadMessage
{
    return "sasas";
};

- (void)signal:(int)number
{
    NSLog(@"打电话给%i", number);
}
- (int)sendMessageWithNumber:(int)number andContent:(char *)content
{
    NSLog(@"发短信给%i,内容为%s", number, content);
    return 1;
}
+ (int)sum:(int)value1 :(int)value2
{
    return value1 + value2;
}
@end
int main(int argc, const char * argv[]) {
    Iphone *p = [Iphone new];
    p->_color = kIColorWhite;
    p->_cpu = 1;
    p->_model = 2.2;
    [p about];
    return 0;
}
